home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Draw / Sources / DrawCont.cpp < prev    next >
Encoding:
Text File  |  1996-12-16  |  26.0 KB  |  839 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawCont.cpp
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Author:                Mary Boetcher
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef DRAWCONT_H
  15. #include "DrawCont.h"
  16. #endif
  17.  
  18. #ifndef DRAWPART_H
  19. #include "DrawPart.h"
  20. #endif
  21.  
  22. #ifndef DRAWCLIP_H
  23. #include "DrawClip.h"
  24. #endif
  25.  
  26. #ifndef BASESHP_H
  27. #include "BaseShp.h"
  28. #endif
  29.  
  30. #ifndef GROUPSHP_H
  31. #include "GroupShp.h"
  32. #endif
  33.  
  34. #ifndef DRAWPRXY_H
  35. #include "DrawPrxy.h"
  36. #endif
  37.  
  38. #ifndef UTILS_H
  39. #include "Utils.h"
  40. #endif
  41.  
  42. #ifndef DRAWLINK_H
  43. #include "DrawLink.h"
  44. #endif
  45.  
  46. #ifndef DRWPRMSE_H
  47. #include "DrwPrmse.h"
  48. #endif
  49.  
  50. #ifndef DRAWSEL_H
  51. #include "DrawSel.h"
  52. #endif
  53.  
  54. // ----- Part Layer -----
  55.  
  56. #ifndef FWUTIL_H
  57. #include "FWUtil.h"
  58. #endif
  59.  
  60. #ifndef FWPRESEN_H
  61. #include "FWPresen.h"
  62. #endif
  63.  
  64. #ifndef FWKIND_H
  65. #include "FWKind.h"
  66. #endif
  67.  
  68. // ----- OS Layer -----
  69.  
  70. #ifndef FWRECT_H
  71. #include "FWRect.h"
  72. #endif
  73.  
  74. #ifndef FWODGEOM_H
  75. #include "FWODGeom.h"
  76. #endif
  77.  
  78. #ifndef FWSUSINK_H
  79. #include "FWSUSink.h"
  80. #endif
  81.  
  82. #ifndef FWBARRAY_H
  83. #include "FWBArray.h"
  84. #endif
  85.  
  86. #ifndef FWFILEAC_H
  87. #include "FWFileAc.h"
  88. #endif
  89.  
  90. #ifndef SLMixOS_H
  91. #include "SLMixOS.h"
  92. #endif
  93.  
  94. // ----- Foundation Layer -----
  95.  
  96. #ifndef FWSTREAM_H
  97. #include "FWStream.h"
  98. #endif
  99.  
  100. #ifndef FWSUSINK_H
  101. #include "FWSUSink.h"
  102. #endif
  103.  
  104. #ifndef FWMEMORY_H
  105. #include "FWMemory.h"
  106. #endif
  107.  
  108. // ----- OpenDoc Includes -----
  109.  
  110. #ifndef SOM_Module_OpenDoc_StdProps_defined
  111. #include <StdProps.xh>
  112. #endif
  113.  
  114. #ifndef SOM_ODTranslation_xh
  115. #include <Translt.xh>
  116. #endif
  117.  
  118. #ifndef SOM_ODShape_xh
  119. #include <Shape.xh>
  120. #endif
  121.  
  122. #ifndef SOM_ODStorageUnit_xh
  123. #include <StorageU.xh>
  124. #endif
  125.  
  126. #ifndef SOM_ODSession_xh
  127. #include <ODSessn.xh>
  128. #endif
  129.  
  130. //========================================================================================
  131. //    Runtime Information
  132. //========================================================================================
  133.  
  134. #ifdef FW_BUILD_MAC
  135. #pragma segment odfdraw
  136. #endif
  137.  
  138. FW_DEFINE_AUTO(CDrawPartContent)
  139. FW_DEFINE_AUTO(CDrawSelectionContent)
  140. FW_DEFINE_AUTO(CDrawUndoContent)
  141. FW_DEFINE_AUTO(CDrawPromiseContent)
  142. FW_DEFINE_AUTO(CDrawLinkContent)
  143. FW_DEFINE_AUTO(CDrawLinkSourceContent)
  144.  
  145. //========================================================================================
  146. //    class CDrawPartContent
  147. //========================================================================================
  148.  
  149. //----------------------------------------------------------------------------------------
  150. //    CDrawPartContent::CDrawPartContent
  151. //----------------------------------------------------------------------------------------
  152. //    CDrawPartContent constructor
  153.  
  154. CDrawPartContent::CDrawPartContent(Environment* ev, CDrawPart* part) :
  155.     CDrawContent(ev, part, FW_kZeroRect) // Size doesn't matter
  156. {
  157.     FW_END_CONSTRUCTOR
  158. }
  159.  
  160. //----------------------------------------------------------------------------------------
  161. //    CDrawPartContent::~CDrawPartContent
  162. //----------------------------------------------------------------------------------------
  163. //    CDrawPartContent destructor
  164.  
  165. CDrawPartContent::~CDrawPartContent()
  166. {
  167.     FW_START_DESTRUCTOR
  168. }
  169.  
  170. //----------------------------------------------------------------------------------------
  171. //    CDrawPartContent::PostInternalizeShape
  172. //----------------------------------------------------------------------------------------
  173.  
  174. void CDrawPartContent::PostInternalizeShape(Environment* ev, const FW_CPoint& offset, CBaseShape* shape, short index)
  175. {
  176.     shape->OffsetShape(ev, -offset.x, -offset.y);
  177.     shape->SetExternalizationIndex(index);    // so links can find their shapes
  178. }
  179.  
  180. //----------------------------------------------------------------------------------------
  181. //    CDrawPartContent::MoveBackward
  182. //----------------------------------------------------------------------------------------
  183.  
  184. FW_Boolean CDrawPartContent::MoveBackward()
  185. {
  186.     FW_Boolean didIt = FALSE;
  187.  
  188.     CBaseShape* shape = fShapeList->First();
  189.     CBaseShape* previous = NULL;
  190.     while (shape != NULL)
  191.     {
  192.         if (shape->IsSelectedShape() && previous != NULL && !previous->IsSelectedShape())
  193.         {
  194.             shape->Acquire();
  195.             fShapeList->RemoveAndRelease(shape);
  196.             fShapeList->AddBefore(previous, shape);    
  197.             shape->Release();
  198.             shape = previous;            
  199.             didIt = TRUE;
  200.         }
  201.         else
  202.             previous = shape;
  203.         
  204.         shape = fShapeList->After(shape);
  205.     }
  206.  
  207.     return didIt;
  208. }
  209.  
  210. //----------------------------------------------------------------------------------------
  211. //    CDrawPartContent::MoveForward
  212. //----------------------------------------------------------------------------------------
  213.  
  214. FW_Boolean CDrawPartContent::MoveForward()
  215. {
  216.     FW_Boolean didIt = FALSE;
  217.     
  218.     CBaseShape* shape = fShapeList->Last();
  219.     CBaseShape* next = NULL;
  220.     while (shape != NULL)
  221.     {
  222.         if (shape->IsSelectedShape() && next != NULL && !next->IsSelectedShape())
  223.         {
  224.             shape->Acquire();
  225.             fShapeList->RemoveAndRelease(shape);
  226.             fShapeList->AddAfter(next, shape);        
  227.             shape->Release();
  228.  
  229.             shape = next;            
  230.             didIt = TRUE;
  231.         }
  232.         else
  233.             next = shape;
  234.             
  235.         shape = fShapeList->Before(shape);
  236.     }
  237.         
  238.     return didIt;
  239. }
  240.  
  241. //----------------------------------------------------------------------------------------
  242. //    CDrawPartContent::MoveToBack
  243. //----------------------------------------------------------------------------------------
  244.  
  245. void CDrawPartContent::MoveToBack()
  246. {
  247.     CShapeCollection extract;
  248.     ExtractSelection(&extract);
  249.     
  250.     CShapeCollectionIterator ite(&extract);
  251.     for (CBaseShape* shape = ite.Last(); ite.IsNotComplete(); shape = ite.Previous())
  252.     {
  253.         fShapeList->AddFirst(shape);
  254.     }
  255. }
  256.  
  257. //----------------------------------------------------------------------------------------
  258. //    CDrawPartContent::MoveToFront
  259. //----------------------------------------------------------------------------------------
  260.  
  261. void CDrawPartContent::MoveToFront()
  262. {
  263.     CShapeCollection extract;
  264.     ExtractSelection(&extract);
  265.     
  266.     CShapeCollectionIterator ite(&extract);
  267.     for (CBaseShape* shape = ite.First(); ite.IsNotComplete(); shape = ite.Next())
  268.     {
  269.         fShapeList->AddLast(shape);
  270.     }
  271. }
  272.  
  273. //----------------------------------------------------------------------------------------
  274. //    CDrawPartContent::ExtractSelection
  275. //----------------------------------------------------------------------------------------
  276.  
  277. void CDrawPartContent::ExtractSelection(CShapeCollection* extract)
  278. {
  279.     // ----- Create the extract list -----
  280.     CShapeCollectionIterator ite(fShapeList);
  281.     CBaseShape* shape;
  282.     for (shape = ite.First(); ite.IsNotComplete(); shape = ite.Next())
  283.     {
  284.         if (shape->IsSelectedShape())
  285.             extract->AddLast(shape);
  286.     }
  287.         
  288.     // ----- Remove then from the shape list -----
  289.     CShapeCollectionIterator ite2(extract);
  290.     for (shape = ite2.First(); ite2.IsNotComplete(); shape = ite2.Next())
  291.     {
  292.         fShapeList->RemoveAndRelease(shape);
  293.     }
  294. }
  295.  
  296. //----------------------------------------------------------------------------------------
  297. //    CDrawPartContent::NewShape
  298. //----------------------------------------------------------------------------------------
  299.  
  300. CBaseShape* CDrawPartContent::NewShape(Environment* ev, unsigned short shapeType)
  301. {    
  302. FW_UNUSED(ev);
  303.     CBaseShape *theShape = NULL;
  304.  
  305.     FW_ASSERT(shapeType != kProxyShape);        // We should never create a proxyShape this way
  306.     
  307.     switch (shapeType)
  308.     {
  309.         case kLineShape:
  310.             theShape = FW_NEW(CLineShape, (fDrawPart));
  311.             break;
  312.             
  313.         case kTextShape:
  314.             theShape = FW_NEW(CTextShape, (fDrawPart));
  315.             break;
  316.         
  317.         case kRectShape:
  318.             theShape = FW_NEW(CRectShape, (fDrawPart));
  319.             break;
  320.             
  321.         case kOvalShape:
  322.             theShape = FW_NEW(COvalShape, (fDrawPart));
  323.             break;
  324.             
  325.         case kRRectShape:
  326.             theShape = FW_NEW(CRoundRectShape, (fDrawPart, fDrawPart->GetRoundRectRadius(), fDrawPart->UseRoundEnds()));
  327.             break;
  328.     }
  329.     
  330.     return theShape;
  331. }
  332.  
  333. //----------------------------------------------------------------------------------------
  334. //    CDrawPartContent::NewPromise
  335. //----------------------------------------------------------------------------------------
  336.  
  337. FW_CPromise* CDrawPartContent::NewPromise(    Environment* ev, 
  338.                                             ODStorageUnit* su, 
  339.                                             FW_StorageKinds storageKind, 
  340.                                             FW_CCloneInfo* cloneInfo)
  341. {
  342. FW_UNUSED(su);
  343.     // Part caontent can only be asked to promise itself  in CloneInto, in which case it's necessary
  344.     // first test for existence of kODPropContentFrame
  345.     
  346.     FW_ASSERT(storageKind != FW_kPartStorage);
  347.     FW_ASSERT(su->Exists(ev, kODPropContentFrame, (ODValueType)NULL, 0));
  348.         
  349.     // The promise resolver in OpenDoc seems to choke when trying to fulfill a promise made to a
  350.     // link during a drop.  For a link of intrinsic content, the net result (besides an assertion failure
  351.     // in debug version of openDoc) is that the destination doesn't update.  But when the promise was
  352.     // written in the cloneInto method of a single embedded frame, the resultant failure inevitably 
  353.     // leads to a crash.  The difference of is that in the first case, as soon as the link dest attempts
  354.     // to read the content, the operation fails, leaving the destination intact.  In the single frame
  355.     // case, the container, which owns the link dest, has no problem reading the embedded frame.  The 
  356.     // failure occurs as the new embedded part attempts to initialize from storage.  This apparently leaves
  357.     // the container in a bad state, so it crashes the next time an update is attempted.
  358.     
  359.     // for now, we'll avoid that situation:
  360.     if (storageKind == FW_kLinkStorage)
  361.         return NULL;
  362.     
  363.     // ----- Make a copy of myself -----
  364.     CDrawPromiseContent* promisedContent = FW_NEW(CDrawPromiseContent, (ev, fDrawPart, this));
  365.  
  366.     // ----- Create a promise object -----
  367.     return new CDrawPromise(ev, storageKind, cloneInfo, promisedContent);
  368. }
  369.  
  370.  
  371. //========================================================================================
  372. //    class CDrawSelectionContent
  373. //========================================================================================
  374.  
  375. //----------------------------------------------------------------------------------------
  376. //    CDrawSelectionContent::CDrawSelectionContent
  377. //----------------------------------------------------------------------------------------
  378. //    CDrawSelectionContent constructor
  379.  
  380. CDrawSelectionContent::CDrawSelectionContent(Environment* ev, CDrawPart* part, CDrawSelection* selection) :    
  381.     CDrawContent(ev, part, selection->GetDragRect()),
  382.     fDrawSelection(selection)
  383. {
  384.     FW_END_CONSTRUCTOR
  385. }
  386.  
  387. //----------------------------------------------------------------------------------------
  388. //    CDrawSelectionContent::~CDrawSelectionContent
  389. //----------------------------------------------------------------------------------------
  390. //    CDrawSelectionContent destructor
  391.  
  392. CDrawSelectionContent::~CDrawSelectionContent()
  393. {
  394.     FW_START_DESTRUCTOR
  395. }
  396.  
  397. //----------------------------------------------------------------------------------------
  398. //    CDrawSelectionContent::NewPromise
  399. //----------------------------------------------------------------------------------------
  400.  
  401. FW_CPromise* CDrawSelectionContent::NewPromise(Environment* ev, ODStorageUnit* su, FW_StorageKinds storageKind, FW_CCloneInfo* cloneInfo)
  402. {
  403. FW_UNUSED(su);
  404.  
  405.     // update our content rect before copying self for promise.
  406.     fContentRect = fDrawSelection->GetDragRect();
  407.     
  408.     // ----- Make a copy of myself -----
  409.     CDrawPromiseContent* promisedContent = FW_NEW(CDrawPromiseContent, (ev, fDrawPart, this));
  410.  
  411.     // ----- Create a promise object -----
  412.     return new CDrawPromise(ev, storageKind, cloneInfo, promisedContent);
  413. }
  414.  
  415. //----------------------------------------------------------------------------------------
  416. //    CDrawSelectionContent::IncorporateEmbeddedFrame
  417. //----------------------------------------------------------------------------------------
  418.  
  419. void CDrawSelectionContent::IncorporateEmbeddedFrame(Environment* ev, 
  420.                                                           FW_CEmbeddingFrame* scopeFrame,
  421.                                                           ODFrame* embeddedFrame,
  422.                                                           ODShape* suggestedShape,
  423.                                                           ODTypeToken viewType)
  424. {
  425.     fDrawSelection->CloseSelection(ev);
  426.     CProxyShape* insertedShape = AddSingleEmbeddedFrame(ev, 
  427.                                                         scopeFrame, 
  428.                                                         NULL, 
  429.                                                         embeddedFrame, 
  430.                                                         suggestedShape, 
  431.                                                         viewType);    
  432.                                                         
  433.     PostInternalizeShape(ev, FW_kZeroPoint, insertedShape, 1);
  434.     insertedShape->Release();
  435. }
  436.  
  437. //----------------------------------------------------------------------------------------
  438. //    CDrawSelectionContent::IncorporateEmbeddedPart
  439. //----------------------------------------------------------------------------------------
  440.  
  441. void CDrawSelectionContent::IncorporateEmbeddedPart(Environment* ev, 
  442.                                                       FW_CEmbeddingFrame* scopeFrame,
  443.                                                       ODPart* embeddedPart, 
  444.                                                       ODShape* suggestedShape,
  445.                                                       ODTypeToken viewType)
  446. {
  447.     fDrawSelection->CloseSelection(ev);
  448.     CProxyShape* insertedShape = AddSingleEmbeddedFrame(ev, 
  449.                                                         scopeFrame, 
  450.                                                         embeddedPart, 
  451.                                                         NULL, 
  452.                                                         suggestedShape, 
  453.                                                         viewType);    
  454.                                                         
  455.     PostInternalizeShape(ev, FW_kZeroPoint, insertedShape, 1);    
  456.     insertedShape->Release();
  457. }
  458.  
  459. //----------------------------------------------------------------------------------------
  460. //    CDrawSelectionContent::PostInternalizeShape
  461. //----------------------------------------------------------------------------------------
  462.  
  463. void CDrawSelectionContent::PostInternalizeShape(Environment* ev, const FW_CPoint& offset, CBaseShape* shape, short index)
  464. {
  465. FW_UNUSED(offset);
  466.     shape->SetExternalizationIndex(index);    // so links can find their shapes
  467.  
  468.     // ----- Add the shape to the right places -----
  469.     fDrawPart->AddShapeToPart(ev, shape);    // Add to the part data
  470.     
  471.     // ----- Shape has already been added to the selection list (fShapeList)
  472.     fDrawSelection->ShapeAdded(ev, shape);
  473. }
  474.  
  475. //----------------------------------------------------------------------------------------
  476. //    CDrawSelectionContent::AcquireSuggestedFrameShape
  477. //----------------------------------------------------------------------------------------
  478.  
  479. ODShape* CDrawSelectionContent::AcquireSuggestedFrameShape(Environment* ev)
  480. {
  481.     FW_CRect selectionRect = fDrawSelection->GetDragRect();
  482.     selectionRect.Place(FW_kZeroPoint);
  483.     
  484.     return ::FW_NewODShape(ev, selectionRect);
  485. }
  486.  
  487. //========================================================================================
  488. //    class CDrawUndoContent
  489. //========================================================================================
  490.  
  491. //----------------------------------------------------------------------------------------
  492. //    CDrawUndoContent::CDrawUndoContent
  493. //----------------------------------------------------------------------------------------
  494. //    CDrawUndoContent constructor
  495.  
  496. CDrawUndoContent::CDrawUndoContent(Environment* ev, CDrawPart* part, CDrawSelection* selection) :
  497.     CDrawContent(ev, part, selection->GetDrawContent(ev)),
  498.     fDrawSelection(selection)
  499. {
  500.     FW_END_CONSTRUCTOR
  501. }
  502.  
  503. //----------------------------------------------------------------------------------------
  504. //    CDrawUndoContent::~CDrawUndoContent
  505. //----------------------------------------------------------------------------------------
  506. //    CDrawUndoContent destructor
  507.  
  508. CDrawUndoContent::~CDrawUndoContent()
  509. {
  510.     FW_START_DESTRUCTOR
  511. }
  512.  
  513. //----------------------------------------------------------------------------------------
  514. //    CDrawUndoContent::RemoveShapeSelection
  515. //----------------------------------------------------------------------------------------
  516.  
  517. void CDrawUndoContent::RemoveShapeSelection(Environment *ev)
  518. {
  519.     // Select the saved shapes
  520.     fDrawSelection->SelectContent(ev, this);
  521.  
  522.     // Clear the selected shapes
  523.     fDrawSelection->ClearSelection(ev);
  524.  
  525. }
  526.  
  527. //----------------------------------------------------------------------------------------
  528. //    CDrawUndoContent::RestoreShapeSelection
  529. //----------------------------------------------------------------------------------------
  530.  
  531. void CDrawUndoContent::RestoreShapeSelection(Environment *ev)
  532. {
  533.     // Add the saved shapes back into the part
  534.     CDrawContentShapeIterator ite(this);
  535.     for (CBaseShape* shape = ite.First(); ite.IsNotComplete(); shape = ite.Next())
  536.     {
  537.         shape->RestoreShape(ev);
  538.     }
  539.  
  540.     // Redraw the restored shapes
  541.     RedrawShapes(ev);
  542.  
  543.     // Select the saved shapes
  544.     fDrawSelection->SelectContent(ev, this);
  545. }
  546.  
  547. //----------------------------------------------------------------------------------------
  548. //    CDrawUndoContent::RemoveFromLinks
  549. //----------------------------------------------------------------------------------------
  550. void CDrawUndoContent::RemoveFromLinks(Environment* ev)
  551. {
  552.     // Remove the saved shapes from any link sources they're in
  553.     CDrawContentShapeIterator it(this);
  554.     for (CBaseShape* shape = it.First(); it.IsNotComplete(); shape = it.Next())
  555.     {
  556.         CDrawPublishLink* linkSource = shape->GetPublishLink();
  557.         if (linkSource)
  558.         {
  559.             linkSource->RemoveShape(ev, shape);
  560.         }
  561.  
  562.         CDrawSubscribeLink* link = shape->GetSubscribeLink();
  563.         if (link)
  564.         {
  565.             link->Unregister(ev);
  566.             fDrawPart->GetLinkManager(ev)->RemoveFromDestLinkList(ev, link);
  567.         }
  568.     }
  569. }
  570.  
  571. //----------------------------------------------------------------------------------------
  572. //    CDrawUndoContent::RestoreLinks
  573. //----------------------------------------------------------------------------------------
  574. void CDrawUndoContent::RestoreLinks(Environment* ev)
  575. {
  576.     // Add the saved shapes back into any link sources they were in
  577.     CDrawContentShapeIterator it(this);
  578.     for (CBaseShape* shape = it.First(); it.IsNotComplete(); shape = it.Next())
  579.     {
  580.         CDrawPublishLink* linkSource = shape->GetPublishLink();
  581.         if (linkSource)
  582.         {
  583.             linkSource->AddShape(ev, shape);
  584.         }
  585.         
  586.         CDrawSubscribeLink* link = shape->GetSubscribeLink();
  587.         if (link)
  588.         {
  589.             link->Register(ev, fDrawPart);
  590.             fDrawPart->GetLinkManager(ev)->AddToDestLinkList(ev, link);
  591.         }
  592.     }
  593. }
  594.  
  595. //----------------------------------------------------------------------------------------
  596. //    CDrawUndoContent::DeleteEmptyLinkSources
  597. //----------------------------------------------------------------------------------------
  598. void CDrawUndoContent::DeleteEmptyLinkSources(Environment* ev)
  599. {
  600.     // Check for link sources left empty because all their shapes were removed
  601.     FW_CLinkManager* linkMgr = fDrawPart->GetLinkManager(ev);
  602.  
  603.     CDrawContentShapeIterator it(this);
  604.     for (CBaseShape* shape = it.First(); it.IsNotComplete(); shape = it.Next())
  605.     {
  606.         CDrawPublishLink* linkSource = shape->GetPublishLink();
  607.         if (linkSource && linkSource->IsEmpty())
  608.         {
  609.             linkMgr->BreakSourceLink(ev, linkSource);
  610.             delete linkSource;
  611.         }
  612.     }
  613. }
  614.  
  615. //----------------------------------------------------------------------------------------
  616. //    CDrawUndoContent::DeleteSavedShapesAndLinks
  617. //----------------------------------------------------------------------------------------
  618. void CDrawUndoContent::DeleteSavedLinks(Environment* ev)
  619. {
  620.     FW_UNUSED(ev);
  621.     
  622.     CBaseShape* shape;
  623.     
  624.     // Before deleting the shapes, make sure they are not promised
  625.     CDrawContentShapeIterator ite(this);
  626.     for (shape = ite.First(); ite.IsNotComplete(); shape = ite.Next())
  627.     {
  628.         // Check for an orphaned link and delete it
  629.         CDrawSubscribeLink* link = shape->GetSubscribeLink();
  630.         if (link)
  631.             delete link;
  632.     }        
  633. }
  634.  
  635. //----------------------------------------------------------------------------------------
  636. //    CDrawUndoContent::CommitPasteDone
  637. //----------------------------------------------------------------------------------------
  638. void CDrawUndoContent::CommitPasteDone(Environment* ev)
  639. {
  640.     CBaseShape* shape;
  641.     
  642.     // Before releasing the shapes, make sure they are not promised
  643.     CDrawContentShapeIterator ite(this);
  644.     for (shape = ite.First(); ite.IsNotComplete(); shape = ite.Next())
  645.     {
  646.         shape->ShapeCommitPasteDone(ev);
  647.     }
  648. }
  649.  
  650.  
  651. //========================================================================================
  652. //    class CDrawPromiseContent
  653. //========================================================================================
  654.  
  655. //----------------------------------------------------------------------------------------
  656. //    CDrawPromiseContent::CDrawPromiseContent
  657. //----------------------------------------------------------------------------------------
  658. //    CDrawPromiseContent constructor
  659.  
  660. CDrawPromiseContent::CDrawPromiseContent(Environment* ev, 
  661.                                         CDrawPart* part, 
  662.                                         CDrawContent* content) :
  663.     CDrawContent(ev, part, content)
  664. {
  665.     FW_END_CONSTRUCTOR
  666. }
  667.  
  668. //----------------------------------------------------------------------------------------
  669. //    CDrawPromiseContent::~CDrawPromiseContent
  670. //----------------------------------------------------------------------------------------
  671. //    CDrawPromiseContent destructor
  672.  
  673. CDrawPromiseContent::~CDrawPromiseContent()
  674. {
  675.     FW_START_DESTRUCTOR
  676. }
  677.  
  678. //----------------------------------------------------------------------------------------
  679. //    CDrawPromiseContent::IsOKtoWrite
  680. //----------------------------------------------------------------------------------------
  681.  
  682. FW_Boolean CDrawPromiseContent::IsOKtoWrite(Environment* ev, CBaseShape* shape)
  683. {
  684. FW_UNUSED(ev);
  685. FW_UNUSED(shape);
  686.     return TRUE;
  687. }
  688.  
  689. //----------------------------------------------------------------------------------------
  690. //    CDrawPromiseContent::PromiseShape
  691. //----------------------------------------------------------------------------------------
  692.  
  693. void CDrawPromiseContent::PromiseShape(Environment* ev, FW_StorageKinds storageKind, FW_Boolean state)
  694. {
  695. FW_UNUSED(ev);
  696.     CDrawContentShapeIterator ite(this);
  697.     for (CBaseShape *shape = ite.First(); ite.IsNotComplete(); shape = ite.Next())
  698.         shape->Promised(storageKind, state);
  699. }
  700.  
  701.  
  702. //========================================================================================
  703. //    class CDrawLinkSourceContent
  704. //========================================================================================
  705.  
  706. //----------------------------------------------------------------------------------------
  707. //    CDrawLinkSourceContent::CDrawLinkSourceContent
  708. //----------------------------------------------------------------------------------------
  709. //    CDrawLinkSourceContent constructor
  710.  
  711. CDrawLinkSourceContent::CDrawLinkSourceContent(    Environment* ev, 
  712.                                                 CDrawPart* part, 
  713.                                                 CDrawContent* selectedContent,
  714.                                                 CDrawPublishLink* linkSrc) :
  715.     CDrawPromiseContent(ev, part, selectedContent),
  716.     fLinkSource(linkSrc)
  717. {
  718.     FW_END_CONSTRUCTOR
  719. }
  720.  
  721. //----------------------------------------------------------------------------------------
  722. //    CDrawLinkSourceContent::~CDrawLinkSourceContent
  723. //----------------------------------------------------------------------------------------
  724. //    CDrawLinkSourceContent destructor
  725.  
  726. CDrawLinkSourceContent::~CDrawLinkSourceContent()
  727. {
  728.     FW_START_DESTRUCTOR
  729. }
  730.  
  731. //----------------------------------------------------------------------------------------
  732. //    CDrawLinkSourceContent::NewPromise
  733. //----------------------------------------------------------------------------------------
  734. FW_CPromise* CDrawLinkSourceContent::NewPromise(Environment* ev,  ODStorageUnit* su, FW_StorageKinds storageKind,  FW_CCloneInfo* cloneInfo)//Override
  735. {
  736. FW_UNUSED(su);
  737.  
  738.     // ----- Create a promise object -----
  739.     return new CDrawPromise(ev, storageKind, cloneInfo, this, fLinkSource);
  740. }
  741.  
  742.  
  743. //========================================================================================
  744. //    class CDrawLinkContent
  745. //========================================================================================
  746.  
  747. //----------------------------------------------------------------------------------------
  748. //    CDrawLinkContent::CDrawLinkContent
  749. //----------------------------------------------------------------------------------------
  750. //    CDrawLinkContent constructor
  751.  
  752. CDrawLinkContent::CDrawLinkContent(Environment* ev, CDrawPart* part, CDrawSubscribeLink* link) :
  753.     CDrawContent(ev, part, FW_kZeroRect),
  754.     fLink(link)
  755. {
  756.     // This constructor is called when a new destination link is created
  757. }
  758.  
  759. //----------------------------------------------------------------------------------------
  760. //    CDrawLinkContent::CDrawLinkContent
  761. //----------------------------------------------------------------------------------------
  762. //    CDrawLinkContent constructor
  763.  
  764. CDrawLinkContent::CDrawLinkContent(Environment* ev, CDrawSubscribeLink* link, CDrawPart* part, CDrawLinkContent* content)
  765. :    CDrawContent(ev, part, content),
  766.     fLink(link)
  767. {
  768.     // This constructor is called when a link is updated (not the first time)
  769.     FW_END_CONSTRUCTOR
  770. }
  771.  
  772. //----------------------------------------------------------------------------------------
  773. //    CDrawLinkContent::~CDrawLinkContent
  774. //----------------------------------------------------------------------------------------
  775. //    CDrawLinkContent destructor
  776.  
  777. CDrawLinkContent::~CDrawLinkContent()
  778. {
  779.     FW_START_DESTRUCTOR
  780. }
  781.  
  782. //----------------------------------------------------------------------------------------
  783. //    CDrawLinkContent::GroupShapes
  784. //----------------------------------------------------------------------------------------
  785. void CDrawLinkContent::GroupShapes(Environment* ev, CGroupShape* group)
  786. {
  787. FW_UNUSED(ev);
  788.     // Add our shapes to the group shape
  789.     CDrawContentShapeIterator it(this);
  790.     for (CBaseShape* shape = it.First(); it.IsNotComplete(); shape = it.Next())
  791.     {
  792.         group->AddShape(shape);
  793.         shape->SetGroupedState(group);
  794.     }
  795. }
  796.  
  797. //----------------------------------------------------------------------------------------
  798. //    CDrawLinkContent::IncorporateEmbeddedFrame
  799. //----------------------------------------------------------------------------------------
  800.  
  801. void CDrawLinkContent::IncorporateEmbeddedFrame(Environment* ev, 
  802.                                                 FW_CEmbeddingFrame* scopeFrame,
  803.                                                 ODFrame* embeddedFrame,
  804.                                                 ODShape* suggestedShape,
  805.                                                 ODTypeToken viewType)
  806. {
  807.     CProxyShape* newShape = AddSingleEmbeddedFrame(ev, 
  808.                                                    scopeFrame, 
  809.                                                    NULL, 
  810.                                                    embeddedFrame, 
  811.                                                    suggestedShape, 
  812.                                                    viewType);
  813.     PostInternalizeShape(ev, FW_kZeroPoint, newShape, 1);                                                
  814.  
  815.     newShape->Release();
  816. }
  817.  
  818. //----------------------------------------------------------------------------------------
  819. //    CDrawLinkContent::IncorporateEmbeddedPart
  820. //----------------------------------------------------------------------------------------
  821.  
  822. void CDrawLinkContent::IncorporateEmbeddedPart(Environment* ev, 
  823.                                             FW_CEmbeddingFrame* scopeFrame,
  824.                                             ODPart* embeddedPart, 
  825.                                             ODShape* suggestedShape,
  826.                                             ODTypeToken viewType)
  827. {
  828.     CProxyShape* newShape = AddSingleEmbeddedFrame(ev, 
  829.                                                    scopeFrame, 
  830.                                                    embeddedPart, 
  831.                                                    NULL, 
  832.                                                    suggestedShape, 
  833.                                                    viewType);
  834.     PostInternalizeShape(ev, FW_kZeroPoint, newShape, 1);                                                
  835.     
  836.     newShape->Release();
  837. }
  838.  
  839.